package com.changcheng.mapper;

import com.changcheng.pojo.Do.PageInfo;
import com.changcheng.pojo.Product;
import com.changcheng.pojo.Role;
import com.changcheng.pojo.User;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;
import org.springframework.stereotype.Repository;

import java.util.List;

/**
 * @author xuan
 * @create 2021--04--12
 */
@Repository
@Mapper
public interface UserMapper {

    //查询总记录数
    int selectItemsNumber();
    //查询所有产品
    List<User> findAllUser(PageInfo pageInfo);

    public User findByUsername(String username);
    public List<String> findPermissionByUserId(int id);
    public void addUser(User user, int roleId);
    public List<Role> findAllRole();
    public int findIdByUsername(String username);
    public void addUserRole(int userId,int roleId);
    public void updatePassword(String password,String username);
    //public List<String> findAllUserAndRole();
    public void deleteUser(int id);
    public void deleteUser_Role(int u_id);

    List<String> findCurrentUserRole(int role);

//    article关联查询
    @Select("select username from user where id = #{id}")
    String selectUserNameById(Integer id);
}
